class Stack {
  constructor() {
    this.arr = [];
  }

  isEmpty() {
    return this.arr.length === 0;
  }

  getSize() {
    return this.arr.length;
  }

  push(data) {
    this.arr.push(data);
  }

  pop() {
    return this.arr.pop();
  }

  peek() {
    return this.arr[this.arr.length - 1];
  }
}

var CQueue = function () {
  this.pushStack = new Stack();
  this.shiftStack = new Stack();
};

/**
 * @param {number} value
 * @return {void}
 */
CQueue.prototype.appendTail = function (value) {
  this.pushStack.push(value);
};

/**
 * @return {number}
 */
CQueue.prototype.deleteHead = function () {
  if (this.shiftStack.isEmpty()) {
    if (this.pushStack.isEmpty()) {
      return -1;
    } else {
      this.swapData();
    }
  }
  return this.shiftStack.pop();
};

CQueue.prototype.swapData = function () {
  while (!this.pushStack.isEmpty()) {
    this.shiftStack.push(this.pushStack.pop());
  }
};

var obj = new CQueue();
obj.appendTail(1);
obj.appendTail(2);
console.log(obj.deleteHead());
console.log(obj.deleteHead());
console.log(obj.deleteHead());
